package com.mspbots.core.report;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mspbots.core.AbstractBaseController;
import com.mspbots.core.report.model.ClientUsageReport;
import com.mspbots.core.report.service.ClientUsageReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

/**
 * @author Dinnes Zhang
 * @date
 */
@Slf4j
@RestController
@RequestMapping("clientUsage")
public class ClientUsageReportController extends AbstractBaseController<ClientUsageReport, ClientUsageReportService> {

    @GetMapping("loadAll")
    public Callable loadAll(ClientUsageReport queryParams) {
        QueryWrapper<ClientUsageReport> queryWrapper = new QueryWrapper<>(queryParams);
        queryWrapper.between(!ObjectUtils.isEmpty(queryParams.getStartDate()), "date", queryParams.getStartDate(), queryParams.getEndDate());
        return () -> this.service.list(queryWrapper);
    }
}
